package com.xd.user.util;

import cn.hutool.core.lang.tree.Tree;
import com.xd.user.api.entity.Permission;

/**
 * @author huboxin
 * @title: TreeUtil
 * @projectName bk
 * @description: 树工具类
 * @date 2020/8/1715:39
 */
public class TreeUtil extends cn.hutool.core.lang.tree.TreeUtil {


    /**
     * 封装菜单TreeNode基础信息
     * @param object 菜单对象
     * @param treeNode 树节点
     * @return 树
     */
    public static Tree<String> createPermissionTreeNode(Permission object, Tree<String> treeNode) {
        Tree<String> stringTree = treeNode.setId(object.getId())
                .setParentId(object.getParentId())
                .setName(object.getName())
                .setWeight(object.getSortOrder());
        stringTree.putExtra("parentId", object.getParentId());
        stringTree.putExtra("title", object.getTitle());
        stringTree.putExtra("sortOrder", object.getSortOrder());
        stringTree.putExtra("status", object.getStatus());
        stringTree.putExtra("delFlag", object.getDelFlag());
        stringTree.putExtra("icon", object.getIcon());
        stringTree.putExtra("level", object.getLevel());
        stringTree.putExtra("buttonType", object.getButtonType());
        stringTree.putExtra("url", object.getUrl());
        stringTree.putExtra("path", object.getPath());
        stringTree.putExtra("type", object.getType());
        stringTree.putExtra("component", object.getComponent());
        return stringTree;
    }
}
